<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/7/24
 * Time: 14:12
 */

namespace app\common\model;


use think\Model;

class DeliveryOrder extends Model
{

    public function delivery(){
        return $this->hasOne('Delivery', 'id', 'delivery_id')->bind([
            'bus_num'
        ]);
    }

    public function user(){
        return $this->hasOne('User', 'id', 'user_id')->bind([
            'travel_name'=>'business_name'
        ]);
    }

    public function order()
    {
        return $this->hasOne('Order', 'id', 'order_id')->bind([
            'begin_city',
            'end_city',
            'use_day',
            'pay_status',
            'order_status'=>'status'
        ]);
    }

    public function getPayTimeAttr($value){
        return date('Y-m-d H:i', $value);
    }


    public function getStatusAttr($value){
        $statusArr = ['未支付','待出行','出行中','待评价','已完成','已取消'];
        return $statusArr[$value];
    }

    //获取签名图片
    public function signature(){
        return $this->hasOne('user_signature', 'id', 'signature_id')->bind('thumb');
    }


}